package Demo05.InnerClassThread;
//匿名内部类实现线程创建
//匿名：没有名字
//内部类：写在其他内部的类
public class Demo01InnerClassThread {
    public static void main(String[] args) {
        //线程父类是Thread
        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "-->" + "黑马");
                }
            }
        }.start();
        //线程接口Runnable
        Runnable r = new Runnable (){
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "-->" + "程序员");
                }
            }
        };
        new Thread(r).start();
        //简化接口方式
        new Thread(new Runnable(){
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "-->" + "传智播客");
                }
            }
        }).start();

    }
}
